<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>

    <script>

        // 狗子  
        //   名字
        //   年龄
        //   叫声

        // function dog(name , age , say) {
        //     console.log('狗的名字是' + name + '年龄是' + age + '叫声是' + say);
        // }


        // dog('小黑' , 2 , '汪')



        function Dog(name , age , say) {
            this.name = name ;
            this.age = age ;
            this.say = say ;
            
        }

        Dog.prototype.speak = function() {
            console.log('狗的名字是' + this.name + '年龄是' + this.age + '叫声是' + this.say);
        }



        const d = new Dog('小黑' , 2 , '汪');


        console.log(d);

        d.speak() ;

        

    </script>
    
</body>
</html>